home *** CD-ROM | disk | FTP | other *** search
- Path: news.ichange.com!newsmaster
- From: Jesse Liberty <jl@staff.ichange.com>
- Newsgroups: comp.lang.c++
- Subject: Re: what happens w/delete called twice ?
- Date: Fri, 23 Feb 1996 17:40:13 -0500
- Organization: AT&T
- Message-ID: <312E424D.67F8@staff.ichange.com>
- References: <kcc.423.0EE12CF6@interaccess.com>
- NNTP-Posting-Host: 140.244.99.60
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (Win95; I)
- CC: jl@staff.ichange.com
-
- kcc wrote:
-
- > Can someone tell me... what happens when delete is called twice for the same [pointer]?
-
- The answer is that your program crashes right away... if you are lucky. If you are not lucky, it crashes later.
-
- When you delete a pointer, set it to zero. It is then safe to delete it again.
-
- delete struct_p;
-
- struct_p = 0; // add this to your code
-
- delete struct_p; // now safe, has no affect.
-
-
-
- --
- Jesse Liberty jl@staff.ichange.com
- AT&T CIS: 72241,72
- Teach Yourself C++ In 21 Days SAMS 1994
- Teach Yourself MORE C++ In 21 Days SAMS 1995
-